<?php
namespace app\common\model;


use think\Db;
use think\Model;

/**  YSF
 *   广告模型  Model
 *   Date: 2018/7/31
 * Class BannerModel
 * @package app\common\model
 */
class BannerModel extends Model
{
    // 表名
    protected $dbName = 'banner';

    // 列表查询
    public function getAll($where, $page, $pageSize, $field, $order)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->field($field)
                    ->page($page, $pageSize)
                    ->order($order)
                    ->select();
        return $result;
    }

    // 数量统计
    public function getCount($where)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->count();
        return $result;
    }

    // 添加
    public function add($data)
    {
        $result = Db::name($this->dbName)
                    ->insertGetId($data);
        return $result;
    }

    // 单条查询
    public function getOne($where)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->find();
        return $result;
    }

    // 编辑
    public function edit($where, $data)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->update($data);
        return $result;
    }

}